<li class="property_attribute">
  <div>
    <%= property_attribute.label :presentation %>
    <%= property_attribute.autocomplete_field :presentation, autocomplete_property_attribute_presentation_admin_properties_path(:property_id => property_attribute.object.property.id), :class => "property_attribute_presentation", :maxlength => 35, :size => 16, :node_id => property_attribute.object.id %>

    <%= property_attribute.label :value_type %>
    <%= property_attribute.select :value_type, options_for_select([["#{t 'enumerations.property.value_type.value'}", "value"], ["#{t 'enumerations.property.value_type.select'}", "select"], ["#{t 'enumerations.property.value_type.choice'}", "choice"]], property_attribute.object.value_type), {}, {:onchange => "$('.#{dom_id(property_attribute.object, :choice)}').hide(); if($(this).val() == 'select') {$('##{dom_id(property_attribute.object, :enum_group)}').show();} else {if($(this).val() == 'choice') {$('##{dom_id(property_attribute.object, :choice)}').show();} else {$('##{dom_id(property_attribute.object, :value)}').show();}};"} %>

    <span style="float: right;"><%= link_to_remove_fields("Smazat vlastnost", property_attribute, "property_attribute") %></span>

    <%= property_attribute.fields_for :property_value do |property_value| %>
      <div id="<%= dom_id(property_attribute.object, :value) %>" style="<%= property_attribute.object.value_type == "value" ? "" : "display: none;" %>" class="<%= dom_id(property_attribute.object, :choice) %>">
        <ul>
          <li>
            <%= property_value.label :value %>
            <%= property_value.text_field :value, :maxlength => 60, :size => 25 %>

            <%= property_value.collection_select :metric_id, Metric.all, :id, :presentation, {:include_blank => true}, {:id => dom_id(property_value.object, :metric)} %>
          </li>
        </ul>
      </div>

      <div id="<%= dom_id(property_attribute.object, :enum_group) %>" style="<%= property_attribute.object.value_type == "select" ? "" : "display: none;" %>" class="<%= dom_id(property_attribute.object, :choice) %>">
        <%= property_attribute.fields_for :property_enum_group do |enum_group| %>
          <p>
            <%= enum_group.label :include_blank %>
            <%= enum_group.check_box :include_blank %>
            <%= enum_group.hidden_field :_destroy, :value => "1" %>
          </p>

          <ul>
            <%= enum_group.fields_for :property_enum_values do |enum_value| %>
              <li><%= enum_value.text_field :value, :maxlength => 60, :size => 25 %></li>
            <% end %>
          </ul>
        <% end %>
      </div>

      <div id="<%= dom_id(property_attribute.object, :choice) %>" style="<%= property_attribute.object.value_type == "choice" ? "" : "display: none;" %>" class="<%= dom_id(property_attribute.object, :choice) %>">
        <ul>
          <li>
            <label>Ne&nbsp;<%= property_value.radio_button :value, "1", :value => "1", :checked => (true if property_value.object.value.to_s != "1") %></label>
            <label>Ano&nbsp;<%= property_value.radio_button :value, "0", :value => "1" %></label>
          </li>
        </ul>
      </div>
    <% end %>

    <%= property_attribute.hidden_field :node_parent_id, :class => "property_attribute_parent_id", :size => 4 %>
    <%= property_attribute.hidden_field :node_next_id,   :class => "property_attribute_next_id", :size => 4 %>
    <%= property_attribute.hidden_field :node_prev_id,   :class => "property_attribute_prev_id", :size => 4 %>
    <%= property_attribute.hidden_field :node_id,        :class => "property_attribute_node_id", :size => 4, :value => property_attribute.object.id %>
  </div>

  <% unless property_attribute.object.children.blank?  %>
    <ol>
      <% property_attribute.object.children.each do |pa| %>
        <%= property.fields_for :property_attributes, pa do |property_attribute| %>
          <%= render :partial => "property_attributes", :locals => {:property_attribute => property_attribute, :property => property} %>
        <% end %>
      <% end %>
    </ol>
  <% end %>
</li>